Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix release header sorting #29

Merged
merged 1 commit into from
Apr 20, 2021
Merged

Fix release header sorting #29

merged 1 commit into from
Apr 20, 2021

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Apr 20, 2021

The release header sorting was broken in two ways. First, the sort function was totally broken - it returned a boolean instead of the expected -1 or 1. Second, the release link generation would always consider the numerical previous release to be the previous release for comparison purposes, even if it was released after.

The sorting function now correctly returns numbers, as Array.prototype.sort expects. The release link logic has been updated to ensure the "previous" release is both numerically and chronologically previous as well.

We don't yet validate that the releases are sorted chronologically, but that is the assumption for now. We can add validation using release dates at some point in the future.

@Gudahtt Gudahtt requested a review from a team as a code owner April 20, 2021 18:48
@Gudahtt
Copy link
Member Author

Gudahtt commented Apr 20, 2021

These bugs were discovered while working on unit tests for #28. See the branchingChangelog fixture in validateChangelog.test.js for an example changelog that exposes this problem.

@Gudahtt Gudahtt mentioned this pull request Apr 20, 2021
The release header sorting was broken in two ways. First, the sort
function was totally broken - it returned a boolean instead of the
expected `-1` or `1`. Second, the release link generation would
always consider the _numerical_ previous release to be the previous
release for comparison purposes, even if it was released _after_.

The sorting function now correctly returns numbers, as
`Array.prototype.sort` expects. The release link logic has been updated
to ensure the "previous" release is both numerically and
chronologically previous as well.

We don't yet validate that the releases are sorted chronologically, but
that is the assumption for now. We can add validation using release
dates at some point in the future.
@Gudahtt
Copy link
Member Author

Gudahtt commented Apr 20, 2021

The change in logic here is a bit... nuanced, but the intent was explained in some detail in the inline comments. Please let me know if something is still unclear!

Copy link

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The change in logic matches the comments and, at least to me, was not difficult to understand.

@Gudahtt Gudahtt merged commit 22c894b into main Apr 20, 2021
@Gudahtt Gudahtt deleted the fix-release-header-sorting branch April 20, 2021 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants